home *** CD-ROM | disk | FTP | other *** search
Gui4CLI script | 1999-12-03 | 2.4 KB | 78 lines |
- G4C
-
- ; -----------------------------------------------------------
- ; Example of how to load and show an image on a new screen
- ; fast. It also uses the Palette command.
- ; -----------------------------------------------------------
- ; =======================================================
-
- winbig 0 0 0 0 '' ; screen sized window, no title..
- wintype 00001100 ; borderless window
- screen myscreen ; use the screen we'll create below
-
- ; The image (alias "mybgpic") will be shown by using it
- ; as the background for the above window..
-
- WinBackGround image mybgpic 0
-
- ; -----------------------------------------------------------
- ; On loading we create a screen and then call the routine
- ; that will ask for, load and show a picture. The picture is
- ; loaded as "mybgpic" and shown as the background of our
- ; window. We load another pic on RMB..
- ; -----------------------------------------------------------
-
- xOnLoad
- makescreen myscreen 640/512/8/0x8004 ""
- gosub #this LoadPic
-
- xOnRMB
- gosub #this LoadPic
-
- ; -----------------------------------------------------------
- ; On closing (ie when the file requester is cancelled) we quit,
- ; freeing the image and closing the screen..
- ; -----------------------------------------------------------
-
- xOnQuit
- guiclose #this
- killscreen myscreen
- freeimage mybgpic
-
- ; -----------------------------------------------------------
- ; Load picture and display it..
- ; -----------------------------------------------------------
-
- xRoutine LoadPic
- local x/y/w/h ; local throw-away vars..
-
- ; reset the main 4 colors on the new screen, so that the
- ; ASL requester is visible..
- setcolor #this 0 9 9 10
- setcolor #this 1 0 0 0
- setcolor #this 2 15 15 15
- setcolor #this 3 15 10 5
-
- ; get picture name
- picname = ''
- ReqFile -1 -1 300 -40 "Choose Background:" LOAD picname sys:
-
- if $picname > '' ; if user selected a picture..
- guiclose #this ; close window (if it was open)
-
- freeimage mybgpic ; free previous image (if any)
- loadimage $picname mybgpic NOREMAP ; load new - no need to remap.
-
- info image mybgpic ; resize & center window using-
- x = $((640-$$image.w)/2) ; info from internal vars
- y = $((512-$$image.h)/2)
- changegad #this 0 $x $y $$image.w $$image.h ""
-
- guiopen #this ; re-open window
- palette set mybgpic myscreen ; set new palette..
-
- else ; if user cancelled, quit..
- guiquit #this
- endif
-
-